/********************************************************************

Write Date: 2015/04/22
Author: Apple
>>>> Create class ClassMetaManager
	
*********************************************************************/
#pragma once
#include "ooputils_global.h"
#include <QMap>
#include "Singleton.h"
#include "Object.h"



_NS_OOP_BEGIN



/**
 * Class ClassMetaManager is a application-wide singleton to manage metas of 
 * classes. See Object.h for detail about meta of a class. As a user, you 
 * needn't care about what the class does. All functions are called by codes 
 * in the framework.
 *
 * @remarks 2015/04/22, Apple
 */
class ClassMetaManager : public Singleton< ClassMetaManager >
{

	friend class Singleton< ClassMetaManager >;

public:

	/**
	 * Register a class's meta. The class must be inherited from Object and 
	 * contain code fragment about meta (see the *_META macros defined in 
	 * Object.h). If a meta of the class already exists, it will be overwritten.
	 *
	 * @param r_metaInfo - the meta of a class
	 */
	void registerClass (Object::Meta& r_metaInfo);

	/**
	 * Get the class name - meta map
	 *
	 * @return the class name - meta map
	 */
	QMap< QString, Object::Meta >& getClassName2MetaMap ();

	/**
	 * Get the meta of a class by its class name. The class must has been 
	 * registered by calling registerClass.
	 *
	 * @param r_className - the class name
	 * @return the meta of the class
	 * @throw ClassMetaNotFoundException - if the class has not been registered
	 */
	Object::Meta& getMeta (QString& r_className) throw (ClassMetaNotFoundException);

private:

	/* The map to store all classes' metas registered */
	QMap< QString, Object::Meta > _map_className_meta;

	/**
	 * Create a ClassMetaManager.
	 */
	ClassMetaManager ();

};



_NS_OOP_END